using System;
using System.Data;

using SqlHelperForCry.Common;

namespace Torch.WL.Entity
{
    [Table("Tb_Sys_ModuleType", "ModuleTypeID", "Torch.WL.ConnectionString")]
	public class Tb_Sys_ModuleType : Info
	{
		#region SQL column name consts 
		public const string SQLCOL_MODULETYPEID = "ModuleTypeID";
		public const string SQLCOL_MODULETYPENAME = "ModuleTypeName";
		public const string SQLCOL_MODULETYPEORDER = "ModuleTypeOrder";
		public const string SQLCOL_MODULETYPEDESCRIPTION = "ModuleTypeDescription";
		public const string SQLCOL_MODULETYPEDEPTH = "ModuleTypeDepth";
		public const string SQLCOL_MODULETYPESUPERIORID = "ModuleTypeSuperiorID";
		public const string SQLCOL_MODULETYPECOUNT = "ModuleTypeCount";
		#endregion


		#region Contructors
		/// <summary>
		/// Construct empty entity
		/// </summary>
		public Tb_Sys_ModuleType () {}

		/// <summary>
		/// Construct entity by primary key, other fields will be assigned by 
		/// "Load" method.
		/// </summary>
		public Tb_Sys_ModuleType (int ModuleTypeID)
		{
			this.ModuleTypeID = ModuleTypeID;
		}
		#endregion

		public override void Init (DataRow row)
		{
			ModuleTypeID = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_MODULETYPEID]);
			ModuleTypeName = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_MODULETYPENAME]);
			ModuleTypeOrder = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_MODULETYPEORDER]);
			ModuleTypeDescription = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_MODULETYPEDESCRIPTION]);
			ModuleTypeDepth = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_MODULETYPEDEPTH]);
			ModuleTypeSuperiorID = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_MODULETYPESUPERIORID]);
			ModuleTypeCount = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_MODULETYPECOUNT]);
		}

		#region Properties 
		#region Property <int> ModuleTypeID
		[Property("ModuleTypeID", 4, SqlDbType.Int, true, true)]
		public int ModuleTypeID 
		{
			get { return _ModuleTypeID; }
			set { _ModuleTypeID = value; }
		}
		private int _ModuleTypeID = int.MinValue;
		#endregion

		#region Property <string> ModuleTypeName
		[Property("ModuleTypeName", 60, SqlDbType.NVarChar, false, false)]
		public string ModuleTypeName 
		{
			get { return _ModuleTypeName; }
			set { _ModuleTypeName = value; }
		}
		private string _ModuleTypeName = null;
		#endregion

		#region Property <int> ModuleTypeOrder
		[Property("ModuleTypeOrder", 4, SqlDbType.Int, false, false)]
		public int ModuleTypeOrder 
		{
			get { return _ModuleTypeOrder; }
			set { _ModuleTypeOrder = value; }
		}
		private int _ModuleTypeOrder = int.MinValue;
		#endregion

		#region Property <string> ModuleTypeDescription
		[Property("ModuleTypeDescription", 100, SqlDbType.NVarChar, false, false)]
		public string ModuleTypeDescription 
		{
			get { return _ModuleTypeDescription; }
			set { _ModuleTypeDescription = value; }
		}
		private string _ModuleTypeDescription = null;
		#endregion

		#region Property <int> ModuleTypeDepth
		[Property("ModuleTypeDepth", 4, SqlDbType.Int, false, false)]
		public int ModuleTypeDepth 
		{
			get { return _ModuleTypeDepth; }
			set { _ModuleTypeDepth = value; }
		}
		private int _ModuleTypeDepth = int.MinValue;
		#endregion

		#region Property <int> ModuleTypeSuperiorID
		[Property("ModuleTypeSuperiorID", 4, SqlDbType.Int, false, false)]
		public int ModuleTypeSuperiorID 
		{
			get { return _ModuleTypeSuperiorID; }
			set { _ModuleTypeSuperiorID = value; }
		}
		private int _ModuleTypeSuperiorID = int.MinValue;
		#endregion

		#region Property <int> ModuleTypeCount
		[Property("ModuleTypeCount", 4, SqlDbType.Int, false, false)]
		public int ModuleTypeCount 
		{
			get { return _ModuleTypeCount; }
			set { _ModuleTypeCount = value; }
		}
		private int _ModuleTypeCount = int.MinValue;
		#endregion
		#endregion


		public bool LoadByIdentity(int ModuleTypeID)
		{
			return DataAccess.SelectByIdentity(this, Convert.ToInt64(ModuleTypeID));
		}


		public bool DeleteByIdentity()
		{
			return DataAccess.DeleteByIdentity(this);
		}
	}
}
